﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using ISHotelApp.Database;

namespace ISHotelApp.XML
{
    public class LoadFromXML
    {
        public static List<Host> loadHostsList()
        {
            List<Host> hoste = new List<Host>();
            try
            {
                XDocument xdoc = XDocument.Load("Hoste.xml");
                if (xdoc != null)
                {
                    var xmlHoste =
                        (from l in xdoc.Descendants("Host")
                         
                         select new Host()
                         {
                             rodne_cislo = l.Element("Rodne_cislo").Value,
                             jmeno = l.Element("Jmeno").Value,
                             prijmeni = l.Element("Prijmeni").Value,
                             ulice = l.Element("Ulice").Value,
                             mesto = l.Element("Mesto").Value,
                             psc = Convert.ToInt32(l.Element("PSC").Value),
                             telefon = Convert.ToInt32(l.Element("Telefon").Value),
                             email = l.Element("E-mail").Value,
                         }
                        ).ToList();
                    hoste = xmlHoste;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return hoste;
        }

        public Host loadHost()
        {
            Host host =new Host();

            return host;
        }
    }
}
